package com.idealighter.game.games.orderma.struct;

import com.idealighter.game.games.common.AbstractSeat;
import com.idealighter.game.games.common.SeatState;

import java.util.List;
import java.util.concurrent.ScheduledFuture;

/**
 * 血战到底座位 .
 * 
 * @date 2016年8月23日 上午10:24:46
 *
 */

public class OderMaSeat extends AbstractSeat {

  public final OderMaTable table;
  // 血战到底牌
  public final OderMaSeatCards cards = new OderMaSeatCards(this);
  // 换牌数量
  public int exchangeNum = -1;
  // 换牌麻将
  public List<Integer> exchangeMjs;
  // 是否结束(胡牌就结束)
  public boolean over = false;
  // 步骤(准备、定缺、换牌、出牌、抢牌)定时Future
  public ScheduledFuture<?> stepFuture = null;
  // 碰的抢牌状态
  public OderMaGrabState pengState = null;
  // 杠的抢牌状态
  public OderMaGrabState gangState = null;
  // 胡的抢牌状态
  public OderMaGrabState huState = null;
  // 摸牌数量
  public int drawCount = 0;

  public OderMaSeat(int order, OderMaTable table) {
    super(order);
    this.table = table;
  }

  /**
   * 重置座位数据 .
   */
  public void reset() {
    this.totalChips = 0;
    this.cards.reset();
    this.exchangeNum = -1;
    this.exchangeMjs = null;
    this.state = SeatState.SEATED;
    this.over = false;
    this.drawCount = 0;
    resetGrabState();
    if (this.stepFuture != null) {
      this.stepFuture.cancel(false);
    }
  }

  /**
   * 重置抢牌状态 .
   */
  public void resetGrabState() {
    this.pengState = null;
    this.gangState = null;
    this.huState = null;
  }

  /**
   * 清空座位数据 .
   */
  public void clear() {
    this.playerId = 0;
    this.playerName = null;
    reset();
  }

  @SuppressWarnings("unchecked")
  @Override
  public OderMaTable table() {
    return table;
  }

}
